import { QXEvent } from "qx-util";
import { IParam, PanelActionType, IPanelAbility, IPanelControllerParams, IPanelStore, PanelController, ICtrlEvent, IPanelController, IPanelModel } from "@/core";
import { usePanelAction, usePanelBasic, usePanelControllerParams, usePanelProps } from "@/hooks/widget/use-panel";
import { List_itempanelControlVO } from './has-panel-list-panel-vo';
import { model } from "./has-panel-list-panel-model";
import PanelService from "@/core/modules/ctrl-service/panel-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@Panel}}-panel/{{spinalCase ctrl.codeName}}-panel-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...usePanelProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...usePanelBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...usePanelAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<PanelActionType, IPanelAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<PanelActionType, IPanelAbility>>,
    otherParams: IParam = {},
): IPanelController<IPanelStore, IPanelAbility> {
	const params: IPanelControllerParams<PanelActionType, IPanelAbility> =
		usePanelControllerParams<IPanelStore, IPanelModel>(model, props, evt, otherParams);
    const ctrlService = new PanelService<List_itempanelControlVO>(List_itempanelControlVO, model.entityCodeName, { model });
  	Object.assign(params, { ctrlService });
  	return new PanelController(params);
}